package com.example.dbdoc.model;

/**
 * 字段信息模型
 * 
 * @author 系统生成
 * @version 1.0.0
 */
public class ColumnInfo {
    
    /** 字段名 */
    private String columnName;
    
    /** 数据类型 */
    private String dataType;
    
    /** 是否允许空 */
    private boolean nullable;
    
    /** 默认值 */
    private String defaultValue;
    
    /** 字段注释 */
    private String comment;
    
    /** 是否自增 */
    private boolean autoIncrement;
    
    /** 字段长度 */
    private Integer columnSize;
    
    /** 小数位数 */
    private Integer decimalDigits;
    
    /** 序列名称（PostgreSQL） */
    private String sequenceName;
    
    public ColumnInfo() {
    }
    
    public ColumnInfo(String columnName, String dataType, boolean nullable, String defaultValue, String comment) {
        this.columnName = columnName;
        this.dataType = dataType;
        this.nullable = nullable;
        this.defaultValue = defaultValue;
        this.comment = comment;
    }
    
    // Getter和Setter方法
    public String getColumnName() {
        return columnName;
    }
    
    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }
    
    public String getDataType() {
        return dataType;
    }
    
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }
    
    public boolean isNullable() {
        return nullable;
    }
    
    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }
    
    public String getDefaultValue() {
        return defaultValue;
    }
    
    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }
    
    public String getComment() {
        return comment;
    }
    
    public void setComment(String comment) {
        this.comment = comment;
    }
    
    public boolean isAutoIncrement() {
        return autoIncrement;
    }
    
    public void setAutoIncrement(boolean autoIncrement) {
        this.autoIncrement = autoIncrement;
    }
    
    public Integer getColumnSize() {
        return columnSize;
    }
    
    public void setColumnSize(Integer columnSize) {
        this.columnSize = columnSize;
    }
    
    public Integer getDecimalDigits() {
        return decimalDigits;
    }
    
    public void setDecimalDigits(Integer decimalDigits) {
        this.decimalDigits = decimalDigits;
    }
    
    public String getSequenceName() {
        return sequenceName;
    }
    
    public void setSequenceName(String sequenceName) {
        this.sequenceName = sequenceName;
    }
    
    /**
     * 获取完整的数据类型描述（包含长度和精度）
     */
    public String getFullDataType() {
        StringBuilder sb = new StringBuilder(dataType);
        
        if (columnSize != null && columnSize > 0) {
            sb.append("(").append(columnSize);
            if (decimalDigits != null && decimalDigits > 0) {
                sb.append(",").append(decimalDigits);
            }
            sb.append(")");
        }
        
        return sb.toString();
    }
    
    @Override
    public String toString() {
        return "ColumnInfo{" +
                "columnName='" + columnName + '\'' +
                ", dataType='" + dataType + '\'' +
                ", nullable=" + nullable +
                ", defaultValue='" + defaultValue + '\'' +
                ", comment='" + comment + '\'' +
                ", autoIncrement=" + autoIncrement +
                '}';
    }
}